Skip to content

inflation_history, fitting_distributions: state what pandas now warns about - #876

Open
mmcky wants to merge 1 commit into
mainfrom
silence-pandas-deprecations
Open

mmcky wants to merge 1 commit into
mainfrom
silence-pandas-deprecations

Conversation

@mmcky

@mmcky mmcky commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What

Two cells print a pandas warning into their output. This states what pandas asks for, keeping the results the same:

Lecture Before After The warning
inflation_history df_list.append(pd.concat(sheet_list, axis=1)) df_list.append(pd.concat(sheet_list, axis=1, sort=True)) Pandas4Warning: "Sorting by default when concatenating all DatetimeIndex is deprecated. In the future, pandas will respect the default of sort=False." sort=True keeps today's sorted result.
fitting_distributions monthly = times.dt.to_period('M').value_counts().sort_index() monthly = times.dt.tz_localize(None).dt.to_period('M').value_counts().sort_index() UserWarning: "Converting to PeriodArray/Index representation will drop timezone information." times is in UTC, so dropping the zone first gives the same months.

Both were found by the environment scan of 2026-11-19 and are in intro's own builds. This is part of reporting lecture fixes upstream to each lecture's source of truth (QuantEcon/project-monorepo#77).

Validation

Done on 2026-11-22, a full validation; the evidence is in the comment below. Fresh builds with no cache of this pull request and of main, every notebook executed, both green. In the two lectures both warnings are gone, and every other output and figure is identical.

This changes lecture content, so it needs a person's review.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WT8bMacV9Lmy1VLUc6XJoL

… about

Two cells printed a pandas warning into their output:

- inflation_history: pd.concat of the sheets, which all have a
  DatetimeIndex, sorts the joined index by default, which pandas 3
  deprecates (Pandas4Warning: "Sorting by default when concatenating all
  DatetimeIndex is deprecated"). `sort=True` keeps today's sorted result.
- fitting_distributions: `times` is in UTC, and converting it to monthly
  periods drops the time zone, with a UserWarning. Dropping it first with
  `tz_localize(None)` gives the same months, without the warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WT8bMacV9Lmy1VLUc6XJoL
@netlify

netlify Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for taupe-gaufre-c4e660 ready!

Name Link
🔨 Latest commit acff0f1
🔍 Latest deploy log https://app.netlify.com/projects/taupe-gaufre-c4e660/deploys/6b02c2510d9b17f7b03b12fe
😎 Deploy Preview https://deploy-preview-876--taupe-gaufre-c4e660.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request November 22, 2026 10:28 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request November 22, 2026 10:29 Inactive
@mmcky

mmcky commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Validation: a full validation

Two fresh builds with no cache, each executing all 54 notebooks, -W --keep-going, both green:

Build Run
main at 8db8a99, this branch's base, 2026-11-22 44991424113
this pull request at acff0f1, 2026-11-22 45013689650

This pull request's first fresh build, 45012267153, failed on eight pages, all with HTTP 429 (Too Many Requests) while downloading data from QuantEcon/data-lectures. That day thirteen validation builds started at once, and GitHub rate-limited the downloads. The run above is the same build again, later.

The two changed lectures. In each, the only difference is the changed line itself and the warning, which is gone. Every other output is identical, and so is every figure, byte for byte.

Lecture main this pull request
inflation_history Pandas4Warning: "Sorting by default when concatenating all DatetimeIndex is deprecated…" none
fitting_distributions UserWarning: "Converting to PeriodArray/Index representation will drop timezone information." none

Build logs. The same warning lines on both sides, and no Sphinx warning on either.

The rest of the HTML. 20 of 66 pages differ in all. Besides the two above, there are three kinds of difference, as between any two builds:

  • Output noise: random draws, memory addresses and timings, on 7 pages.
  • Figure file names: on 15 pages, because a figure's file is named by its content, and an unseeded figure that is drawn again gets a new name.
  • The status page: build times.

The warnings in the other pages' outputs are the same on both sides.

@mmcky
mmcky marked this pull request as ready for review November 22, 2026 11:02
Copilot AI adaptive review requested due to automatic review settings November 22, 2026 11:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human review is needed to confirm that the executable lecture changes preserve the intended pandas-version-specific warning behavior and instructional outputs across regenerated notebooks and external data.

No open issues 🎉

What changed in this PR

This PR updates two executable lecture examples to make pandas behavior explicit, removing deprecation and timezone-conversion warnings while preserving existing results.

Changes:

  • Sets sort=True when concatenating time-indexed data in inflation_history.
  • Removes timezone information before converting timestamps to monthly periods in fitting_distributions.
  • No actionable code issues identified.
File Description
lectures/​inflation_history.md Makes the concatenation sort behavior explicit for pandas compatibility.
lectures/​fitting_distributions.md Removes UTC timezone information before monthly period conversion.

Review effort: Lite (adaptive)

This branch was previously deployed

1 inactive deployment
pull request — acff0f1b Deployed Nov 22, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants